package modelLayer;

/**
 * This class is a modelLayer class of the MSAS system. It holds
 * information on a single classroom. True to our domain model, the classroom
 * class has no field visibility to any classes in the system. The Class class is itself
 * referenced in TeachingBlock.
 * 
 * @author Danny M�lgaard, Anna Kelemen, Jakob Korsgaard
 * 		   
 * @version 1.3.1
 * 					1.3.1: 		Added more extensive documentation. Verified that
 * 								information contained in the Design Class Diagram,
 * 								is in accordance with the information contained in this
 * 								class.
 * 					1.3.2: 		toString() adjusted
 */
public class ClassRoom {

	private int    id;
	private String name;
	private String purpose;

	/**
	 * Instantiating a ClassRoom object, taking the following parameters:
	 * 
	 * @param	name	String		name of the classroom.
	 */
	public ClassRoom(String name) {
		
		this.setName(name);
		
	}

	/**
	 * Instantiating a ClassRoom object, taking the following parameters:
	 * 
	 * @param	id		int			id of the classroom, as allocated in the database.
	 */
	public ClassRoom (int id) {
		
		this.setId(id);
		
	}
	
	/**
	 * Instantiating a ClassRoom object, taking the following parameters:
	 * 
	 * @param	name	String		name of the classroom.
	 * @param	purpose	String		purpose of the classroom, can be left "blank".
	 * @param	id		int			id of the classroom, as allocated in the database.
	 */
	public ClassRoom(String name, String purpose, int id) {
		
		this.setName(name);
		this.setPurpose(purpose);
		this.setId(id);
		
	}

	/**
	 * Instantiating a ClassRoom object, taking no parameters, altering no variables:
	 */
	public ClassRoom() {
	}

	/**
	 * Assigns a parameter to the id field, defining the uniquely associated id in the 
	 * database.
	 * 
	 * @param 	id			int		the id of the classroom, as allocated in the database.					
	 */
	public void setId(int id) {
	
		this.id = id;

	}
	
	/**
	 * Assigns a parameter to the name field, defining the uniquely associated name in the 
	 * database.
	 * 
	 * @param 	name		String	the name of the classroom.					
	 */
	public void setName(String name) {

		this.name = name;
		
	}
	
	/**
	 * Assigns a parameter to the purpose field.
	 * 
	 * @param 	purpose		String	the purpose of the classroom.					
	 */
	public void setPurpose(String purpose) {

		this.purpose = purpose;

	}
	
	/**
	 * Returns the id of the classroom, as allocated in the database.
	 * 
	 * @return 	id			int		the id of the classroom.
	 */
	public int getId() {

		return this.id;

	}

	/**
	 * Returns the name of the classroom.
	 * 
	 * @return 	name		String	the name of the classroom, uniquely defined in the database.
	 */
	public String getName() {

		return this.name;

	}
	
	/**
	 * Returns the name of the classroom.
	 * 
	 * @return 	purpose		String	the purpose of the classroom.
	 */
	public String getPurpose(){

		return this.purpose;

	}
	

	/**
	 * Overrides the object's default toString() method. Returns the object as a String
	 * literal to the caller.
	 * 
	 * return				String	the ClassRoom object represented as a String object.
	 */
	@Override
	public String toString() {

		//return "Classroom: " + this.name + "(" + id + ")" + ", " + purpose;
		return this.name + ": " + this.purpose;
	}

	/**
	 * Implements a check, to verify if an object is the same
	 * as this object. Uses class identification number to
	 * verify.
	 * 
	 * @param	o		Object	any object type.
	 * @return	true			if: 
	 * 							object is not null, and
	 * 							object is of type ClassRoom, and
	 * 							object id field matches this objects id field.
	 * @return	false			if:
	 * 							object is null, or
	 * 							object is not an instance of ClassRoom, or
	 * 							object id field doesn't match this objects id field.
	 */
	@Override
	public boolean equals(Object o) {
		
		if (o != null && (o instanceof ClassRoom)){
			ClassRoom cr = (ClassRoom) o;
			if (this.getName() != null && this.getName().equals(cr.getName())) {
				return true;
			}
		}
			
		return false;

	}

}
